//
//  WriteCodeViewController.m
//  GetPowerDBO
//
//  Created by 周博 on 2017/7/19.
//  Copyright © 2017年 BogoZhou. All rights reserved.
//

#import "WriteCodeViewController.h"

@interface WriteCodeViewController ()<UITextFieldDelegate>

@end

@implementation WriteCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [_textFieldContent addTarget:self action:@selector(textFieldChangeValue:) forControlEvents:UIControlEventEditingChanged];
}

#pragma mark - 点击事件

- (IBAction)backButtonClick:(UIButton *)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

//点击提交
- (IBAction)sendButtonClick:(UIButton *)sender {
    if ([BGFunctionHelper checkEnglishNum:_textFieldContent.text]) {
        if (_textFieldContent.text.length == 12) {
            [_delegate getWriteCodeType:_typeString codeString:_textFieldContent.text];
        }else{
            kAlert(@"输入长度不正确");
        }
    }else{
        kAlert(@"输入格式不正确");
    }
}


- (void)textFieldChangeValue:(UITextField *)textField{
    NSString *upper = [textField.text uppercaseString];
    if (upper.length >12) {
        upper = [upper substringToIndex:12];
    }
    textField.text = upper;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
